package cn.edu.imnu.Service.impl;

import cn.edu.imnu.Service.DashboardService;
import cn.edu.imnu.entity.po.Stats;
import cn.edu.imnu.entity.vo.Statsvo;
import cn.edu.imnu.mapper.DashboardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class DashboardServiceImpl implements DashboardService {

    @Autowired
    private DashboardMapper dashboardMapper;

    @Override
    public List<Statsvo> getDashboardStats() {
        List<Statsvo> statsList = new ArrayList<>();
        // 医师人数（添加空值处理）
        Integer doctorCount = dashboardMapper.countDoctors();
        statsList.add(new Statsvo("医师人数", doctorCount != null ? doctorCount : 0));

        // 药物种类（添加空值处理）
        Integer drugCount = dashboardMapper.countDrugs();
        statsList.add(new Statsvo("药物种类", drugCount != null ? drugCount : 0));

        // 合作企业（添加空值处理）
        Integer companyCount = dashboardMapper.countCompanies();
        statsList.add(new Statsvo("合作企业", companyCount != null ? companyCount : 0));

        // 入驻药店（添加空值处理）
        Integer pharmacyCount = dashboardMapper.countPharmacies();
        statsList.add(new Statsvo("入驻药店", pharmacyCount != null ? pharmacyCount : 0));

        return statsList;
    }
    @Override
    public List<Map<String, Object>> getDoctorsCountByLevel() {
        return dashboardMapper.countDoctorsByLevel();
    }
}